if __name__=="__main__": 
  # 人脸检测模型路径 
  face_det_kmodel_path="/sdcard/examples/kmodel/face_detection_320.kmodel" 
  # 人脸注册模型路径 
  face_reg_kmodel_path="/sdcard/examples/kmodel/face_recognition.kmodel" 
  # 其它参数 
  anchors_path="/sdcard/examples/utils/prior_data_320.bin" 
  database_dir="/sdcard/examples/utils/db/" 
  database_img_dir="/sdcard/examples/utils/db_img/" 
  face_det_input_size=[320,320] 
  face_reg_input_size=[112,112] 
  confidence_threshold=0.5 
  nms_threshold=0.2 
  anchor_len=4200 
  det_dim=4 
  anchors = np.fromfile(anchors_path, dtype=np.float) 
  anchors = anchors.reshape((anchor_len,det_dim)) 
  max_register_face = 100 #数据库最多人脸个数 
  feature_num = 128 #人脸识别特征维度 
  
   fr=FaceRegistration(face_det_kmodel_path,face_reg_kmodel_path,det_input_size=face_det_input_size,reg_input_size=face_reg_input_size,database_dir=database_dir,anchors=anchors,confidence_threshold=confidence_threshold,nms_threshold=nms_threshold) 
  try: 
    # 获取图像列表 
    img_list = os.listdir(database_img_dir) 
    for img_file in img_list: 
        #本地读取一张图像 
        full_img_file = database_img_dir + img_file 
        print(full_img_file) 
        img = image.Image(full_img_file) 
        img.compress_for_ide() 
        # 转rgb888的chw格式 
        rgb888p_img_ndarry = fr.image2rgb888array(img) 
        # 人脸注册 
        fr.run(rgb888p_img_ndarry,img_file) 
        gc.collect() 
  except Exception as e: 
    sys.print_exception(e) 
  finally: 
    fr.face_det.deinit() 
    fr.face_reg.deinit() 